package ru.niir.goodfil.excel.impl;

import org.apache.commons.beanutils.PropertyUtils;
import ru.niir.goodfil.excel.client.ValueExtractor;

/**
 * @author: Кирилл
 */
public class DefaultValueExtractor implements ValueExtractor {
    private final String propertyName;

    public DefaultValueExtractor(String propertyName) {
        this.propertyName = propertyName;
    }

    public Object extract(Object o) {
        Object value = null;
        try {
            value = PropertyUtils.getProperty(o, propertyName);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return value;
    }
}
